@import "../../../style/globals.scss";
@import "./grid.scss";

$headline-background-bg: $ts-main-blue-color;
$headline-foreground-bg: white;

.version-bar {
  background-color: $ts-dark-bg-color;
  text-align: center;
  color: white;
  padding: 0.7rem 2rem;
  margin: 0;

  p {
    margin: 0;
    a {
      color: $ts-main-blue-lightest-color;
    }
  }
}

.grey-box {
  background-color: #d8d8d8;
  padding: 18px;
  margin-right: 20px;
  box-sizing: border-box;
  a {
    color: black;
  }
}

.clicky-grey-button,
.grey-box {
  &.first {
    margin-left: 20px;
  }

  &.last {
    margin-right: 0;
  }
}

.split-row > .clicky-grey-button {
  flex: 1;
}

@mixin flat-button {
  background-color: white;
  color: black;
  padding: 1rem 1rem;
  text-decoration: none;
  cursor: pointer;

  @media screen and (-ms-high-contrast: active) {
    border: 2px solid grey;
  }

  &:hover,
  &.focus {
    background-color: #eee;
  }

  &:active {
    background-color: #ddd;
  }

  .fluid-button-title {
    font-weight: 600;
  }
}

@media (max-width: $screen-sm) {
  main #index-2 {
    h2 {
      font-size: 1.8rem;
      padding-left: 20px;
      padding-right: 20px;
    }

    // Doesn't show because it doens't have a way to generate
    // a height, so hard-code it
    div.headline-diagram {
      height: 400px;
      max-width: 100%;
      overflow-x: hidden;
    }

    // Make it 2s instead of 4s
    .split-row > a {
      min-width: 80%;
      margin-left: 20px !important;
    }

    .grey-box {
      margin-right: 0;
    }

    // Can't fit that much info into one component, just drop the quotes
    .illustration {
      display: none;
    }

    ul.dropdown {
      margin-top: 12px;
    }

    .headline-diagram {
      div.editor.front {
        margin: 20px auto;
        position: static;
      }
      .text {
        overflow-x: scroll;
      }
    }

    #m-stories {
      flex-direction: column;
    }

    #m-stories div.illustration  {
      display: flex;
      justify-content: center;
      order: 1;
      div.bg {
        visibility: hidden;
      }
      div.fg {
        position: static;
        text-align: center;
      }
    }

    #m-stories div.copy {
      margin: 20px auto 0;
      position: static;
      text-align: center;
      order: 2;
      a.migration-button {
        margin: 0 auto;
      }
    }

    .small_full_width {
      width: 100%;
    }

    .github-bar {
      display: none;
    }

    .get-started-section {
      a.get-started {
        background-image: none !important;
        height: auto !important;
        margin: 0 auto;
      }
      flex-direction: column;
    }

    img {
      max-width: 100%;
    }

    h3 {
      text-align: center;
    }
  }
}

@media (max-width: $screen-md) {
  .tag-container {
    .twoslash-annotation.left {
      position: static;
      left: 0;
      bottom: 0;
      top: auto !important;

      svg {
        transform: rotate(44deg) scaleX(-1) translateX(-20px) !important;
      }
    }
    .twoslash-annotation.right {
      display: none;
    }
  }
}

.show-only-small {
  display: none;
}

@media (max-width: $screen-xs) {
  .show-only-small {
    display: block !important;
  }

  #index div.headline-diagram div.editor.front {
    max-width: 300px;
  }
}

#index-2 {
  h1 {
    font-size: 2.5rem;
    line-height: 2.8rem;
    font-weight: 200;
    margin-top: 0;
    padding-right: 40px;

    strong {
      font-weight: 600;
    }
  }

  h2 {
    text-align: center;
    font-weight: 500;
    font-size: 2.5rem;
    line-height: 2.5rem;
    margin-top: 0;
  }

  h3 {
    font-weight: 400;
    font-size: 1.6rem;
    line-height: 1.6rem;
    margin-top: 0;
    margin-bottom: 2.5rem;
  }

  p {
    font-size: 1.2rem;
  }

  .col1 {
    min-width: 230px;

    @media (max-width: "360px") {
      max-width: calc(100% - 2rem);
    }
  }

  .darkblue {
    background-color: $ts-main-blue-darkest-color;
    color: white;
  }

  .blue {
    background-color: $ts-main-blue-color;
    color: white;
  }

  .purple {
    background-color: $ts-muted-purple;
    color: white;
  }

  .dark-green {
    background-color: #086e12;
    color: white;
  }

  .white {
    background-color: white;
    color: black;

    .col1 h3 {
      text-align: center;
    }
    .col1 > p,
    .col2 > p {
      font-size: 1.2rem;
    }
  }

  .light-grey {
    background-color: $ts-light-bg-sandy-color;
    color: black;
  }

  .grey {
    background-color: #d8d8d8;
    padding-bottom: 0;
    div.container {
      padding: 1rem;
    }
  }

  .headline {
    min-height: 420px;
    .col1 {
      padding-bottom: 3rem;
    }
    p {
      padding-right: 20px;
    }

    .container {
      padding-bottom: 0;
      font-size: 1rem;
    }
  }

  .container {
    max-width: 1080px;
    margin: 0 auto;
    padding-top: 64px;
    padding-bottom: 40px;
    display: flex;
    flex-direction: column;
    position: relative;

    .half {
      max-width: 780px;
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      position: relative;

      @media (max-width: "360px") {
        max-width: 100%;
      }
    }
  }

  .headline-diagram {
    display: relative;

    @media screen and (-ms-high-contrast: active) {
      border: 2px solid white;
    }

    pre .code-container {
      overflow: hidden;
      a {
        display: none;
      }
    }

    .editor {
      border: 2px solid #7fa2c9;
      border-radius: 4px;
      width: 540px;

      ul.editor-tabs {
        display: flex;
        flex-direction: row;
        padding: 0;
        margin: 0;
        font-size: 14px;
        li {
          list-style: none;
          padding: 10px;
          a {
            text-decoration: none;
            color: white;
          }
          &.selected {
            text-decoration: underline;
          }
        }
      }

      .min-dark {
        display: none;
      }

      &.front {
        width: 96%;
        border-radius: 8px;

        @media screen and (-ms-high-contrast: active) {
          border: none;
        }
      }
      .error {
        border-left: 0 !important;
      }

      .editor-inner {
        position: relative;
      }

      .titlebar {
        height: 2rem;
        border-bottom: 2px solid #172e38;
        display: flex;
        flex-direction: row;

        .lang {
          margin-left: 6px;
          margin-top: 3px;
          display: none;
        }

        .window-name {
          margin-left: 10px;
          padding-top: 5px;
          display: none;
        }
      }

      .line-error {
        position: absolute;
        left: 0;
        height: 20px;
        width: 22px;
        background-color: $ts-muted-red;
      }

      .underline-error {
        background: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%206%203'%20enable-background%3D'new%200%200%206%203'%20height%3D'3'%20width%3D'6'%3E%3Cg%20fill%3D'%23c94824'%3E%3Cpolygon%20points%3D'5.5%2C0%202.5%2C3%201.1%2C3%204.1%2C0'%2F%3E%3Cpolygon%20points%3D'4%2C0%206%2C2%206%2C0.6%205.4%2C0'%2F%3E%3Cpolygon%20points%3D'0%2C2%201%2C3%202.4%2C3%200%2C0.6'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E")
          repeat-x bottom left;
        padding-bottom: 3px;
      }

      .error-message {
        color: #444d80;
        font-size: 0.8rem;
        font-family: $font-code;
      }

      .error-behind {
        opacity: 0;
      }

      .inline-completions {
        position: relative;

        ul.dropdown {
          display: inline-block;
          position: absolute;
          width: 240px;
          background-color: white;
          color: grey;

          font-family: $font-code;
          font-size: 0.8rem;
          margin: 0;
          padding: 0;

          border-left: 4px solid #4b9edd;

          // Fake the cursor above us
          &::before {
            background-color: white;
            width: 2px;
            position: absolute;
            top: -16px;
            left: -3px;
            content: " ";
          }

          li {
            border-bottom: 1px solid black;
            height: 1rem;
            overflow-x: hidden;
            padding-left: 4px;

            span.result-found {
              color: #4b9edd;
            }
            span.result {
              width: 100px;
              color: black;
              display: inline-block;
            }
          }
        }
      }

      .did-you-mean-icon {
        position: absolute;
      }

      .did-you-mean {
        position: absolute;
      }

      .content {
        display: flex;
        flex-direction: row;

        svg {
          margin: 12px auto;

          path {
            fill: white;
          }
        }

        .text {
          border-top: 1px solid #7fa2c9;
          font-family: $font-code;
          font-size: 0.8rem;
          line-height: 0.95rem;
          height: 260px;

          flex-shrink: 1;
          flex-grow: 1;
          overflow-x: auto;
          position: relative;
          background-color: #235a97;
          border-radius: 0px 0px calc(8px - 2px) calc(8px - 2px);

          pre {
            margin: 0;
            background-color: #235a97;
            border: none;
            code {
              font-size: 14px;
              line-height: 16px;
            }
            .error {
              background-color: #ff000026;
              color: #ffc5c5;
            }
          }

          .language-id {
            display: none;
          }
        }
      }

      .highlight {
        color: #9ed5ff;
      }
    }
    .back .content .text > div {
      padding-right: 200px;
    }
  }

  .next-headline-button {
    @include flat-button;

    position: absolute;
    padding: 3px;
    height: 30px;
    width: 30px;

    display: flex;
    flex-direction: row;
    text-decoration: none;
    bottom: 20px;
    right: 15px;

    align-items: center;
    justify-content: center;
    margin-bottom: 20px;

    svg path {
      fill: black;
    }

    @media screen and (-ms-high-contrast: active) {
      svg path {
        fill: yellow;
      }
    }
  }

  a.get-started {
    @include flat-button;

    margin: 0 auto;
    box-sizing: border-box;
    box-shadow: 0px 4px 20px -6px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 244px;

    // One of these has to be set
    &.short {
      background: $ts-main-blue-color;
      background-position-y: bottom -180px;
      height: 260px;
      outline: 1px solid white;
      color: white;
      &.handbook {
        background-image: url(/images/index/get-started-handbook-blue.svg);
      }
      &.playground {
        background-image: url(/images/index/get-started-playground-blue.svg);
      }
      &.download {
        background-image: url(/images/index/get-started-download-blue.svg);
        background-position: right bottom;
        background-repeat: no-repeat;
      }
      svg path {
        stroke: white;
      }

      &:active {
        background-color: #156fb4;
      }
      &:focus-visible,
      &:hover {
        outline-width: 2px;
        box-shadow: 0px 4px 20px -2px rgba(0, 0, 0, 0.25);
      }
    }

    &.tall {
      background: #ffffff;
      outline: 1px solid #000000;
      color: black;
      height: 342px;
      margin-bottom: 2px;

      &:focus-visible,
      &:hover {
        outline-color: $ts-main-blue-color;
        outline-width: 2px;
        color: $ts-main-blue-color;
        box-shadow: 0px 4px 20px -2px rgba(0, 0, 0, 0.25);
        margin-bottom: 0px;

        svg path {
          stroke: $ts-main-blue-color;
        }
      }
      &:active {
        background-color: #eeeeee;
      }
    }

    display: flex;
    align-items: flex-end;

    .fluid-button-title {
      font-size: 1.4rem;
    }

    svg {
      margin-left: 20px;
      margin-bottom: 10px;
    }

    &:active {
      box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.25);
    }

    &.handbook {
      background-image: url(/images/index/get-started-handbook.svg);
      background-position: left bottom;
      background-repeat: no-repeat;
    }
    &.playground {
      background-image: url(/images/index/get-started-playground.svg);
      background-position: center bottom;
      background-repeat: no-repeat;
    }
    &.download {
      background-image: url(/images/index/get-started-download.svg);
      background-position: right bottom;
      background-repeat: no-repeat;
    }
  }

  .call-to-action {
    display: flex;
    justify-content: center;
    position: relative;

    a.flat-button {
      display: block;
      height: 1.4rem;
      line-height: 1.4rem;
      text-align: center;
      text-decoration: none;
      font-size: 1.2rem;
      @include flat-button;

      &:first-child {
        margin-right: 2rem;
      }
    }

    .handbook-preview {
      background-color: #1a1a1a;
      padding: 4rem;
    }

    .inline-buttons {
      background-color: #1a1a1a;
      display: flex;
      justify-content: center;

      a {
        background-color: #1a1a1a;
        color: white;
        flex: 1;
        margin: 0 !important;
        border-left: 4px solid #00273f;

        &:first-child {
          border-left: none;
        }
        &:active,
        &:hover {
          color: black;
        }
      }
    }
  }

  .cta-redirects {
    overflow-y: hidden;
    > div {
      margin-bottom: -18%;
      position: relative;

      a {
        position: absolute;
        bottom: 55%;
      }
    }
  }

  .release-info {
    width: 100%;
    display: flex;
    flex-direction: row;
    position: relative;

    .needle,
    .needle-head {
      height: 68px;
      width: 2px;
      background-color: black;
      margin-top: -8px;
      position: absolute;
    }

    .needle-head {
      height: 0;
      margin-left: -4px;
      margin-top: -14px;
      border-left: 4px solid transparent;
      border-right: 4px solid transparent;
      border-top: 6px solid black;

      background-color: transparent;
    }

    > div > div {
      display: flex;
      flex-direction: row;
    }
  }

  .bar {
    width: 100%;
    height: 50px;
    margin-left: -1px;
  }

  .separator {
    margin-top: 50px;
    height: 12px;
    width: 1px;
    background-color: black;
  }

  @media screen and (-ms-high-contrast: active) {
    .needle-head {
      opacity: 0;
    }
    .release-info .needle {
      border: 1px solid black;
      height: 80px;
    }
    .release > div,
    .beta > div,
    .rc > div {
      border: 1px solid black;
    }
    form.search:focus {
      border: 1px solid black;
    }
  }

  .release {
    width: 55%;
    .bar {
      background-color: #c4c4c4;
    }
  }
  .beta {
    width: 28%;
    .bar {
      background-color: $ts-main-blue-color;
    }
  }
  .rc {
    width: 17%;
    .bar {
      background-color: $ts-main-blue-darker-color;
    }
  }

  .migrations {
    overflow: hidden;
    &.github #migration_title {
      color: white;
    }
    strong {
      color: #187abf;
    }
  }

  .migrations .container {
    padding-bottom: 0;
  }

  #m-stories {
    position: relative;
    min-height: 370px;

    .controls a {
      background-color: #c4c4c4;
      width: 2rem;
      height: 2rem;
      color: black;
      position: absolute;
      top: 70%;
      text-align: center;
      line-height: 2.5rem;
      z-index: 2;
      display: flex;
      align-items: center;
      justify-content: center;

      &:hover {
        background-color: #eee;
      }

      &:active {
        background-color: #ddd;
        top: calc(70% + 1px);
      }

      &.left {
        left: 0;
      }

      &.right {
        right: 0;
      }
    }

    .copy {
      background: $ts-light-bg-sandy-color;
      background: linear-gradient(
        90deg,
        $ts-light-bg-sandy-color 48%,
        $ts-light-bg-sandy-color-20 100%
      );
      p {
        font-size: 1rem;
      }
    }

    .airbnb {
      .fg {
        padding-top: 40px;
      }
    }

    .goog {
      .illustration .fg {
        padding-top: 40px;
      }
    }

    .copy {
      position: absolute;
      padding-left: 20px;
      padding-right: 30px;
      width: 260px;

      -webkit-transition: opacity 200ms ease-out;
      -moz-transition: opacity 200ms ease-out;
      -o-transition: opacity 200ms ease-out;
      -ms-transition: opacity 200ms ease-out;
      transition: opacity 200ms ease-out;

      p {
        padding: 1rem 0;
      }

      a.migration-button {
        border: 1px solid black;
        color: black;
        text-decoration: none;
        text-align: center;
        width: 60%;
        display: block;
        padding: 8px 0;

        &:hover,
        &:focus {
          background-color: white;
          color: black;
        }
      }
    }

    .illustration {
      .bg {
        position: absolute;
        right: 20px;
      }

      .fg {
        font-size: 1.4rem;
        line-height: 1.6rem;
        width: 370px;
        position: absolute;
        right: 70px;
      }
    }
  }

  .oss {
    width: 100%;

    .icons {
      display: flex;
      flex-direction: row;
      justify-content: space-around;
      flex-wrap: wrap;
      max-width: 800px;
      margin: 0 auto;

      @media screen and (-ms-high-contrast: black-on-white) {
        svg path {
          fill: black;
        }
      }
      @media screen and (-ms-high-contrast: white-on-black) {
        svg path {
          fill: white;
        }
      }

      svg {
        margin: 0 auto;
      }

      a {
        flex: 1;
        margin: 20px;
        color: white;
        text-align: center;
        height: 145px;
        width: 140px;
        max-width: 140px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;

        p {
          padding-bottom: 0;
        }
      }
    }
  }

  .github-bar {
    position: absolute;
    opacity: 0;
    -webkit-transition: opacity 300ms ease-out;
    -moz-transition: opacity 300ms ease-out;
    -o-transition: opacity 300ms ease-out;
    -ms-transition: opacity 300ms ease-out;
    transition: opacity 300ms ease-out;

    &.left {
      left: -200px;
    }
    &.right {
      right: -200px;
    }
  }

  ul#videos {
    padding: 0;
    margin: 0;

    li {
      margin: 0;
      padding: 0;
      list-style: none;
      border-left: 2px solid transparent;

      &.active {
        border-color: black;
      }

      a {
        text-decoration: none;
        color: black;
        font-size: 1rem;
        display: block;
        margin-left: 6px;
      }

      span {
        font-style: italic;
        font-size: 0.8rem;
      }
    }
  }

  .installation-panel {
    .flat-button {
      margin-top: 20px;
      display: block;
      @include flat-button;

      button {
        float: right;
        border: none;
        background-color: transparent;
      }

      svg {
        opacity: 0.5;
        transition: opacity 0.2s linear;
        width: 0.9em;
        height: 0.9em;
        float: right;
        margin-top: 3px;
      }

      &:hover svg {
        opacity: 1;
      }
    }
    .tooltip {
      display: none;
      background-color: rgb(63, 63, 63);
      color: #fff;
      text-align: center;
      padding: 5px 8px;
      border-radius: 2px;
      font-family: $font-code;
      font-size: 14px;
      white-space: pre-wrap;
      border-radius: 2px;
      z-index: 100;
      pointer-events: none;
    }
  }

  #adopt-gradually-content.fancy-scroll {
    height: 1400px;

    #adopt-step-slider {
      position: sticky;
      top: 80px;
      height: 580px;
    }

    #adopt-step-blurb,
    #global-stepper {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 64px;

      margin: 0 auto;
      max-width: 480px;
    }

    #global-stepper {
      display: flex;
      bottom: 32px;

      > div {
        transition: opacity 0.2s;
        opacity: 0.2;
      }
      > div.active {
        opacity: 1;
      }
    }

    .adopt-step {
      transition: opacity 0.2s;
      position: absolute;
      margin-left: auto;
      margin-right: auto;
      padding-top: 200px;

      left: 0;
      right: 0;
      top: 0;
      > div > p {
        display: none;
      }
      .adopt-step-stepper {
        display: none;
      }
    }
  }

  #global-stepper {
    display: none;
  }

  .adopt-step {
    max-width: 480px;
    margin: 20px auto;
    padding-top: 120px;

    pre {
      margin-bottom: 10px;
    }

    > p {
      font-weight: bold;
      margin: 10px 0;
      font-size: 1rem;
    }

    .tag-container p {
      font-size: 1rem;
    }
  }

  .adopt-step-stepper {
    display: flex;
    margin-bottom: 80px;

    div {
      border: 1px solid black;
      // width: 75px;
      display: inline-block;
      flex: 1;
      height: 13px;
      margin-left: 10px;
      position: relative;

      &.yellow,
      &.yellow-hint-blue,
      &.yellow-lot-blue {
        background-color: #ffe200;
      }

      &.yellow-hint-blue:after,
      &.yellow-lot-blue:after {
        content: "";
        position: absolute;
        width: 20%;
        left: 0;
        height: 13px;
        background-color: $ts-main-blue-color;
      }

      &.yellow-lot-blue:after {
        width: 60%;
      }
      &.first {
        margin-left: 0;
      }
    }
  }

  // Convert the shiki CSS for highlighting to instead be red
  .via-delete {
    .highlight {
      background-color: #fee;
    }
    .dim {
      opacity: 1;
    }
  }
}

.yellow {
  background-color: #f1dd3f;
  color: black;
  margin-bottom: -110px;

  .col1 {
    width: 50%;
    align-self: stretch;

    pre {
      overflow: hidden;
      height: 220px;
      code {
        font-size: 14px;
        line-height: 16px;
      }
    }
  }

  a {
    color: black;
  }
}

.darkblue.dt {
  position: relative;

  .dark-blue-trans-bg {
    background-color: rgba(0, 39, 62, 0.77);

    a {
      color: white;
    }
  }

  .dt-background {
    font-size: 1.2rem;
    font-family: $font-code;
    opacity: 0.2;
    position: absolute;
    top: 20px;
    left: 20px;
    width: 80%;
    bottom: 20px;
    overflow: hidden;
  }
}

.flex-column {
  flex-direction: column;
}

.fluid-button {
  background-color: white;
  color: black;
  text-decoration: none;
  padding: 0.5rem 1rem;
  display: flex;

  .fluid-button-title {
    font-weight: 600;
  }

  div.fluid-button-icon {
    min-width: 4rem;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    border-left: 2px solid black;
    margin-right: -1rem;
    margin-left: 1rem;
  }

  &:hover,
  &.focus {
    background-color: #eee;
  }

  &:active {
    background-color: #ddd;
  }
}

.cta .cta-back a {
  position: relative;
  top: 20px;
  left: 20px;
  width: 60px;
}

.transparent-button {
  position: absolute;
  top: 40px;
  left: 20px;
  border: 1px solid white;
  width: 80px;
  padding: 10px;
  cursor: pointer;
  svg {
    margin-right: 8px;
  }
  color: white;
  text-decoration: none;

  &:hover,
  &.focus {
    background-color: #ffffff10;
  }

  &:active {
    background-color: #ffffff20;
    border: 1px solid #ffffff60;
  }
}
